package qna;

import java.io.Reader;
import java.util.List;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;


public class BoardInsertAction extends ActionSupport implements Preparable, ModelDriven<BoardVO>{

	BoardVO board;
	List<BoardVO> boardList;
	
	public String execute() throws Exception{
		Reader reader = Resources.getResourceAsReader("sqlMapConfig.xml");
		SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		reader.close();
		
		sqlMap.insert("insertBoard02", board);
		boardList=sqlMap.queryForList("selectBoard");
		
		return SUCCESS;
	}

	@Override
	public void prepare() throws Exception {
		board = new BoardVO();
		
	}

	@Override
	public BoardVO getModel() {
		
		return board;
	}
	
}
